package com.finer.entity;

import java.io.Serializable;

/**
 * @author 罗梦杰
 * date 2024/9/18 11:23
 * @version 1.0
 */
public class ResponseMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    private String code; // 200 成功 其他 失败
    private String message;
    private Object data;

    public ResponseMessage() {
    }

    public ResponseMessage(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResponseMessage success(Object data) {
        return new ResponseMessage("200", null, data);
    }

    public static ResponseMessage success() {
        return new ResponseMessage("200", null, null);
    }

    public static ResponseMessage error(String code, String message) {
        return new ResponseMessage(code, message, null);
    }

    @Override
    public String toString() {
        return "ResponseMessage{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
